<template>
  <el-dialog :visible.sync="dialogVisible" title="发货信息" width="800px" v-drag2anywhere>
    <el-form :model="formData" ref="form" label-width="90px">
      <el-row>
        <el-col :span="8">
          <el-form-item label="采购时间:">{{formData.reqdate}}</el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="供应商:">{{formData.seller}}</el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户名称:">{{formData.client}}</el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="采购途径:">{{formData.buyroute}}</el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="店铺名称:">
            <span style="margin-right: 10px;">{{formData.shopname}}</span> <a :href="formData.shopurl"
              v-if="formData.shopurl!=''" target="_blank"><i class="el-icon-link"></i></a>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="物流名称:" prop="name">
            <el-select v-model="formData.deliver.name" placeholder="快递或物流名称" filterable allow-create clearable>
              <el-option label="顺丰快递" value="顺丰快递"></el-option>
              <el-option label="中通快递" value="中通快递"></el-option>
              <el-option label="圆通快递" value="圆通快递"></el-option>
              <el-option label="韵达快递" value="韵达快递"></el-option>
              <el-option label="京东快递" value="京东快递"></el-option>
              <el-option label="德邦快递" value="德邦快递"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item label="物流单号:" prop="num">
            <el-input v-model="formData.deliver.num" placeholder="物流单号"></el-input>
          </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="物流备注:">
            <el-input type="textarea" v-model="formData.deliver.memo" placeholder="物流备注信息" :rows="3"></el-input>
          </el-form-item>
        </el-col>

        <el-col>
          <el-form-item label="签收状态">
              <el-select v-model="formData.deliver_ok" placeholder="签收状态">
                <el-option label="待签收" value="0"></el-option>
                <el-option label="已签收" value="1"></el-option>
              </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" size="medium" @click="handleSave">确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default {
    data() {
      return {
        index: -1,
        formData: {
          orderdate: '',
          ordercode: '',
          type: 1,
          deliver: {
            name: '',
            num: '',
            memo: '',
            status: 0
          },
          deliver_ok:0,
        },
        dialogVisible: false,

        postlist: []
      }
    },
    methods: {
      init(index, data) {
        this.index = index;
        this.formData = data;
      },
      handleSave() {
        const params = {
          id: this.formData.id,
          name: this.formData.deliver.name,
          num: this.formData.deliver.num,
          status: this.formData.deliver.num != "" ? 1 : 0,
          memo: this.formData.deliver.memo,
          ok:this.formData.deliver_ok
        }
        this.axios.post("api/admin/buylist/updatedeliver", params).then(res => {
          if (res.status == 200 && res.data.code) {
            this.$message.success({
              message: res.data.msg,
              duration: 1500,
              showClose: true
            });
            this.dialogVisible = false;
            this.$emit("updated", this.index, params);
          } else {
            this.$message.error({
              message: res.data.msg,
              duration: 1500,
              showClose: true
            });
          }
        })
      }
    }
  }
</script>

<style>
</style>
